<?php
session_start();
    
    // Created By : Julian Ponce
    // B.S. Computer Science - De La Salle Canlubang
    // November 3, 2011
    // IN PARAMETERS : documentId
    // 
    // This AJAX Request gets the document setup id of a particular document name.
    // This is used in viewPageSending.php

    include('../includes/siteConfig.php');
    
    // CONNECT TO DATABASE
    $connect = mysql_connect($hostName,$rootName,$dBasePassword) or die ('Unable to connect!');
    mysql_select_db($dBaseName) or die ('Unable to select database!');

    // GET VARIABLES VIA POST METHOD
    $documentName = $_POST['documentName'];
     
    //GET ATTACHMENTS OF THE MAIN DOCUMENT
         $query = 
            "
                SELECT documentSetupId
                FROM DocumentSetup
                WHERE documentName = '$documentName'
            ";
         $result = mysql_query($query) or die ('Error in query: $query. ' . mysql_error());
         $row = mysql_fetch_array($result);
         
         $tempVar['documentSetupId'] = $row['documentSetupId'];
         
    //output the response
    echo json_encode($tempVar);
    
    mysql_free_result($result);
    mysql_close($connect);
?>
